<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/jspf/must/basePath.jspf" %>
<!--后台UI组件Start-->
<%@include file="/WEB-INF/jspf/zj/ligerui/LigerUI.jspf" %>
<%@include file="/WEB-INF/jspf/zj/ztree/ztree.jspf" %>
<%--<%@include file="/WEB-INF/jspf/zj/ligerui/LigerUI_form.jspf" %>--%>
<!--后台UI组件End-->
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <script src="power/syspower/VIEW_SYSPOWER.js" type="text/javascript"></script>
        <script type="text/javascript">
//-------------------------------全局变量-------------------------------------------------
            var UPDATE;
            var GRID;
            var ADD;
            $(function() {
                GRID = $("#divID_GRID").ligerGrid({
                    columns: [
                        {display: '称号', name: 'role_name', width: 190, align: 'left'}
                        , {display: '备注', name: 'role_info', width: 190, align: 'left'}
                        , {display: '创建时间', name: 'cdate', width: 120, align: 'center'}
                    ]
                    , usePager: false
                    , url: 'weixinkeji/dev/power/role/sysrole/manager/s.imy'
                    , width: '500px;'
                    , height: '97%'
                    , onSelectRow: role_click
                });
                $("#toptoolbar").ligerToolBar({items: [
                        {text: '增加', click: add}
                        , {line: true}
                        , {text: '修改', click: update}
                        , {line: true}
                        , {text: '删除', click: dell}
                        , {text: '继承权限', click: f_UserExtedsPower}
                    ]});
                powerTree("#V_SYSPOWERID_ROLE", true);
            });
//-------------------------------GRID列函数-----------------------------------------------
            function role_click(rowdata, rID, rowobj) {
                zt_check("V_SYSPOWERID_ROLE", false);
                var ROLE_POWER = myajax("weixinkeji/dev/power/center/sysrp/manager/s/rolePower.imy", {"rID": rowdata.role_id});
                for (var i = 0; i < ROLE_POWER.length; i++) {
                    setPowerTree("V_SYSPOWERID_ROLE", ROLE_POWER[i].power_id);
                }
            }
            function reloadRole() {
                GRID.reload();
                zt_check("V_SYSPOWERID_ROLE", false);
            }
//-------------------------------增删改操作-----------------------------------------------
            function add() {
                ADD = openURL_Event("角色管理添加", ADD, "power/sysrole/sysrole_A.jsp", 400, 900, f_d);
                ADD.max();
                function f_d() {
                    ADD = null;
                    reloadRole();
                }
            }
            function update() {
                var row = GRID.getSelectedRow();
                if (!row) {
                    msg_tip("错误", "请选择行");
                    return;
                } else if (row.role_id.length > 10) {
                    UPDATE = openURL_Event("角色管理修改", UPDATE, "weixinkeji/dev/power/role/sysrole/adu/update.imy?id=" + row.role_id, 400, 900, f_d);
                    UPDATE.max();
                }
                function f_d() {
                    UPDATE = null;
                    reloadRole();
                }
            }
            function dell() {
                var rows = GRID.getSelectedRows();
                var ids = "";
                for (var i = 0; i < rows.length; i++) {
                    ids = ids + "," + rows[i].role_id;
                }
                ids = ids.substring(1);
                if (rows.length < 1) {
                    msg_tip("操作提示", "请选择行", 200, 50);
                    return;
                } else {
                    if (post_json("weixinkeji/dev/power/role/sysrole/adu/dell.imy", {"id": ids})) {
                        reloadRole();
                    }
                }
            }
            var EXTENDSPOWER_ROLE;
            function f_UserExtedsPower() {
                var row = GRID.getSelectedRow();
                if (null == row || null != EXTENDSPOWER_ROLE)
                    return;
                EXTENDSPOWER_ROLE = openURL_Event("继承权限", EXTENDSPOWER_ROLE, "power/syspower/syspowerCheckbox_role.jsp?role_id=" + row.role_id, 520, 700, f_d);
                function f_d() {
                    EXTENDSPOWER_ROLE = null;
                    reloadRole();
                }
            }
        </script>
    </head>
    <body>  
        <div id="toptoolbar"></div> 

        <div id="divID_GRID" style="margin:0; padding:0; float:left"></div>
        <div>
            <ul id="V_SYSPOWERID_ROLE" class="ztree" style="height: 510px; overflow:auto;"></ul>
        </div>
    </body>
</html>
